package com.cj.user.service;

import com.cj.common.response.Result;
import com.cj.user.entity.File;
import com.cj.user.service.impl.FileFeignFallbackFactory;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Author cheng jun
 * @Description:
 * @Date 2021/5/25 18:03
 */
@FeignClient(value = "file", fallbackFactory = FileFeignFallbackFactory.class)
public interface FileFeignService {

    @RequestMapping(value = "/file/upload", method = RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result<File> upload(@RequestPart("file") MultipartFile file);

    @RequestMapping(value = "/file/downLoad", method = RequestMethod.POST, consumes = MediaType.APPLICATION_PROBLEM_JSON_VALUE)
    Response download(Map<String, Object> map, @RequestParam(value = "response") HttpServletResponse response);

}
